<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html> 
<head>
<%@ include file="/WEB-INF/jsp/include/easyui.jsp" %>
<%@ include file="/WEB-INF/jsp/include/pGrid.jsp" %>
<%@ include file="/WEB-INF/jsp/include/pForm.jsp" %>
<title>用户角色授权</title>
<script>
	$(function(){
		/*添加提交前事件*/
		fn.onBeforeSubmitForm = function(){
			fn.queryParams.userId = fn.data.id;
			var form = $("#easyuiForm").html("");
			$("input:checkbox:checked").clone().appendTo(form);
		};
		fn.resetForm();
		
		/*列表初始化*/
		var gridParam = {
			pagination: true,
			url : "/console/com.fs.base.pojo.Role/list",
			columns : [[ 
			    {"field":"id", checkbox: true } ,
			    {"field" : "roleName", "width" : 120, "title" : "角色名称" }, 
				{ "field" : "roleDesc", "width" : 250, "title" : "角色描述" } 
			]],
			pageSize: 50,
		 	singleSelect: false, 
		 	onLoadSuccess:function(data){
		 		 var param = { userId : fn.data.id ,userId_searchType:'eq' };
		 		 var url = "/console/com.fs.base.pojo.UserRole/getFieldIds/roleId";
		 		 $.getJSON(url, param ,function(roleIds){
		 			roleIds = roleIds.join(",");
		 			$.each(data.rows,function(rIndex,row){
		                if(roleIds.indexOf(row.id)>=0) p.dataGrid.datagrid("checkRow", rIndex);
	                });
		 		 });
		 	}
		};
		p.dataGrid = $(p.dataGrid).datagrid( $.extend({}, p.dataGridParam, gridParam));
		
		$("#toolbar a").on("click", function() {
			var id = $(this).attr("id");
			switch(id){
				case "b_5": p.gridQuery(); break;
				default:break;
			}
		});
	});
</script>
</head>
<body>
	<div class="easyui-panel" data-options="fit:true,border:false" style="padding:10px;">
		<form id="easyuiForm" method="post" action="/console/role/userRoleConfig"  style="display: none;" >
		 <!--类名属性及默认主键id-->
		 <input type="hidden" name="id" value="" />
		</form>
	
		<!-- 工具栏 -->
		<div id="toolbar" class="easyui-panel" style="padding:3px;">
			<!-- 工具栏按钮  -->
	      	<a href="#" class="easyui-linkbutton" iconCls="icon-reload" plain="true" id="b_5">刷新</a>
		</div>
		
		<table id="dataGrid"></table>
	</div>
</body>
</html>